function url_params_parse_obj(url_params) {

    var params = url_params.substring(1);

    var x = params.split("&");

    var access_token;
    var user_id;

    for (var i = 0; i < x.length; i++) {

        var ii = x[i].split('=')

        if (ii[0] == 'access_token') {
            access_token = ii[1]
        } else if (ii[0] == 'user_id') {
            user_id = ii[1]
        }

    }

    return { 'access_token': access_token, 'user_id': user_id }

}

function callCars() {
    var go_time = document.getElementById('go_time').value
    var place_departure = document.getElementById('place_departure').value
    var destination = document.getElementById('destination').value
    var number_people = document.getElementById('number_people').value
    var phone = document.getElementById('phone').value
    var carpool_hitl = document.getElementById('carpool_hitl').value
    var direction = document.getElementById('direction').value
    var params = url_params_parse_obj(location.search)
    var user_id = params.user_id
    var access_token = params.access_token
    url_data = 'go_time=' + go_time
        + '&place_departure=' + place_departure
        + '&destination=' + destination
        + '&number_people=' + number_people
        + '&phone=' + phone
        + '&carpool_hitl=' + carpool_hitl
        + '&direction=' + direction
        + '&user_id=' + user_id
        + '&access_token=' + access_token


    // 1.0 创建一个XMLHttpRequest异步对象的实例
    var xhr = new XMLHttpRequest();
    // 2.0 监听请求状态的变化和服务端响应的状态变化
    xhr.onreadystatechange = function () {
        // 3.0 监听请求的状态
        if (xhr.readyState === 4) {
            // 4.0 监听响应的状态2
            if (xhr.status === 200) {
                // 5.0 服务端响应的数据
                var result = xhr.responseText;
                result = JSON.parse(result);
                // 在这里书写相关的处理逻辑
                if (result.status === 1) {
                    alert('登录成功')
                } else {
                    alert(result.errorMsg)
                    location.href = '/static/logins.html'
                }
                // console.log(result);              
                // 因为字符串不可以直接使用,所以转换成json格式 
            }
        }
    }
    // 6.0 发起请求动作,get post
    // 参数1:请求方式  参数2:请求数据的地址  参数3:是异步还是同步
    // 异步就是true,同步就是false
    // var url = '/access_token_verify?access_token=' + access_token + '&user_id=' + user_id
    var url = '/callcar'
    xhr.open('post', url, true);
    // 7.0 发送请求  (跟服务端建立联系)
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr.send(url_data);
}